<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                template="./../templates/StakeholderPortalTemplate.xhtml">

    <ui:define name="content"> 
            <h:form id="formMain">                     
                <p:fieldset>
                    <h2>View Groupon Purchase Information</h2>
                    <br/>
                    <h:outputText value="GROUPON NAME : #{grouponManagerBean.selectedGroupon.groupon.name}" style="font-weight:bold; text-align:center; font-size:14px"/>
                    <br/>
                    <br/>
                    <h:outputText value="OFFERED BY : #{grouponManagerBean.selectedGroupon.groupon.stakeholder.corpName}" style="font-weight:bold; text-align:center; font-size:14px"/>
                    <br/>
                    <br/>
                    <p:accordionPanel autoHeight="false">
                        <p:tab title="List of Groupon Purchasers">
                            <p:dataTable var="purchase" value="#{grouponManagerBean.grouponPurchaseList}" paginator="true" 
                                         rows="10" emptyMessage="No purchase information found for this groupon" 
                                         selectionMode="single" dblClickSelect="true">
                                <p:column sortBy="#{purchase.id}" filterBy="#{purchase.id}">
                                    <f:facet name="header">
                                        <h:outputText value="ID" />
                                    </f:facet>
                                    <h:outputText value="#{purchase.id}" />
                                </p:column>

                                <p:column sortBy="#{purchase.confirmationId}" filterBy="#{purchase.confirmationId}">
                                    <f:facet name="header">
                                        <h:outputText value="Confirmation ID" />
                                    </f:facet>
                                    <h:outputText value="#{purchase.confirmationId}" />
                                </p:column>

                                <p:column sortBy="#{purchase.groupon.offeredPrice}" filterBy="#{purchase.groupon.offeredPrice}">
                                    <f:facet name="header">
                                        <h:outputText value="Offered Price" />
                                    </f:facet>
                                    <h:outputText value="#{purchase.groupon.offeredPrice}" />
                                </p:column>

                                <p:column sortBy="#{purchase.quantity}" filterBy="#{purchase.quantity}">
                                    <f:facet name="header">
                                        <h:outputText value="Quantity" />
                                    </f:facet>
                                    <h:outputText value="#{purchase.quantity}" />
                                </p:column>

                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Image" />
                                    </f:facet>
                                    <p:graphicImage id="imageDisplay" value="/images/upload/media/#{purchase.groupon.imageURL}"
                                                    height="50" width="70"/> 
                                </p:column>            

                                <p:column sortBy="#{purchase.transactions.get(0).datePaid}" filterBy="#{purchase.transactions.get(0).datePaid}">
                                    <f:facet name="header">
                                        <h:outputText value="Purchase Date" />
                                    </f:facet>
                                    <h:outputText value="#{purchase.transactions.get(0).datePaid}">
                                        <f:convertDateTime dateStyle="full" pattern="EEE, dd/MM/yyyy" timeZone="EST" type="date" />
                                    </h:outputText>
                                </p:column>

                                <p:column sortBy="#{purchase.status}" filterBy="#{purchase.status}">
                                    <f:facet name="header">
                                        <h:outputText value="Status" />
                                    </f:facet>
                                    <h:outputText value="#{purchase.status}" />
                                </p:column>
                            </p:dataTable>
                        </p:tab>
                    </p:accordionPanel> 
                </p:fieldset>
            </h:form>
    </ui:define>
</ui:composition>